package com.abc.base.common.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result<T> {
    private int code;
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        return Result.<T>builder().code(200).message("success").data(data).build();
    }

    public static <T> Result<T> success() {
        return Result.<T>builder().code(200).message("success").data(null).build();
    }

    public static <T> Result<T> success(String msg, T data) {
        return Result.<T>builder().code(200).message(msg).data(data).build();
    }

    public static <T> Result<T> error(String msg) {
        return Result.<T>builder().code(500).message(msg).build();
    }
}
